#! /usr/bin/python
# -*- coding: utf8 -*-

import tensorflow as tf
import numpy as np

# 设置按需使用GPU
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
sess = tf.InteractiveSession(config=config)

from tensorflow.examples.tutorials.mnist import  input_data
mnist = input_data.read_data_sets('/tmp/data/mnist',one_hot=True)
print('training data shape ',mnist.train.images.shape)
print('training label shape ',mnist.train.labels.shape)

'''
Signature: tf.name_scope(*args, **kwds)
Docstring:
Returns a context manager for use when defining a Python op.
'''
# 也就是说，它的主要目的是为了更加方便地管理参数命名。
# 与 tf.Variable() 结合使用。简化了命名
with tf.name_scope('conv1') as scope:
    weights1 = tf.Variable([1.0, 2.0], name='weights')
    bias1 = tf.Variable([0.3], name='bias')

# 下面是在另外一个命名空间来定义变量的
with tf.name_scope('conv2') as scope:
    weights2 = tf.Variable([4.0, 2.0], name='weights')
    bias2 = tf.Variable([0.33], name='bias')